package com.gensdai.leliang.adapter;


import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.gensdai.leliang.R;
import com.gensdai.leliang.utils.ViewHolder;


/**
 * 排序的adapter
 * @author Administrator
 *
 */
public class SortAdapter extends KimiraAdapter<String> {


    LayoutInflater inflater;
    Context context;
    private int pos = -1;
    public SortAdapter(Context context) {
        inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        this.context = context;
    }

    @Override
    public View extralView(int position, View convertView, ViewGroup parent) {
        if(convertView == null){
            convertView = inflater.inflate(R.layout.item_sort,
                    null);
        }
        TextView title = ViewHolder.GetChars(convertView, R.id.title);
        title.setText(getItem(position).toString());
        if(pos == position){
            convertView.setBackgroundColor(Color.parseColor("#f6f6f6"));
            title.setTextColor(context.getResources().getColor(R.color.baseColor));
        }else{
            convertView.setBackgroundResource(R.color.bgColor_new);
            title.setTextColor(context.getResources().getColor(R.color.producttitleColor));
        }
        return convertView;
    }

    public void setSelector(int position){
        this.pos = position;
        notifyDataSetChanged();
    }

}